﻿<%@ page contentType="text/html; charset=utf-8"%>
<%@ page language="java" pageEncoding="utf-8"%>
<%@ page import="com.mysql.jdbc.Driver"%>
<%@ page import="java.sql.*"%>
<html>
<head>
<style rel="sheetstyle" type="text/css">
tr :first-child{
	width:25%;
	height:35px;
}
input.i,input.in{width:100%;border:white;}
</style>
</head>
<body>
<%
String userName="root";
String userpasswd="";
String dbName="a0713225307";

request.setCharacterEncoding("UTF-8");

Object uname=session.getAttribute("uname");

//System.out.println(uname);
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	String u="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userpasswd+"&useUnicode=true&characterEncoding=UTF-8";
    java.sql.Connection con=java.sql.DriverManager.getConnection(u,"root","");
	String sql="select * from users where uName='"+uname+"'";
    Statement statement=con.createStatement();
	ResultSet rs=statement.executeQuery(sql);

%>
<div class="panel-heading" style="background-color:rgb(3, 245, 242);border:white solid 1px;border-radius:0;">
个人信息<button id="editButton" onclick="modifyInfo()" style="float:right;color:white;background-color:rgb(3, 245, 242);border:0;"><span id="uedit" class="glyphicon glyphicon-edit"></button></a>
</div>
<form action="modifyUInfo.jsp" method="post">
<div class="panel-body"id="uInfo">


<table class="table">
<tr><td>昵称</td><td>
<%
while(rs.next()){

%>
<input class="in" type="text" value="<% out.print(rs.getString(1)); %>" readonly /></td></tr>
<tr><td>邮箱</td>
<td><input class="i" name="newE" type="text" value="<% out.print(rs.getString(3)); %>" readonly /></td></tr>
<%
}
%>	
</table>
</div>
</form>
<%
rs.close();
statement.close();
con.close();
%>

<script type="text/javascript">
function modifyInfo(){
	$('.i').removeAttr("readonly");
	$('.i').css({
		"border":"rgb(3, 245, 242) solid 1px",
		"border-radius":"0"
	});
	$('#uInfo').append("<button type='submit' id='add'style='background-color:rgba(3, 245, 242,0.5);border:rgb(3, 245, 242)'>确定修改</button>");
	$('#add').css("float","right");
	$('#editButton').attr("disabled","disabled");
	
	$('#add').click(function(){
			$('#editButton').removeAttr("disabled");
			
		var x;
		if(window.XMLHttpRequest){
			x=new XMLHttpRequest();
		}else{
			x=new ActiveXObject("Microsoft.XMLHTTP");
		}

		x.open("GET","modifyUInfo.jsp");
		x.send();
		
		$('#add').css("display","none");
		$('.i').attr("readonly","readonly");
		$('.i').css("border","white");
	});
}
</script>
</body>
</html>